#include<iostream>
int main()
{
	int input_times, attacks_num,start,end,max=0;
	std::cin >> input_times >> attacks_num;
	int* input = new int[input_times];
	int* s = new int[input_times];
	for (int i = 0; i < input_times; i++)   std::cin >> input[i];
	s[0] = input[0];
	for (int i = 1; i < input_times; i++)   s[i] = s[i - 1] + input[i];
	for (int i = 0; i < attacks_num; i++)
	{
		std::cin >> start >> end;
		if (start >= 2)
		{
			if (max < s[end - 1] - s[start - 2])   max = s[end - 1] - s[start - 2];
		}
		else
		{
			if (max < s[end - 1] - s[start - 2])   max = s[end - 1];
		}
	}
	std::cout << max;
	return 0;
}